pub fn as_u32_from4u8(u: &[u8]) -> u32 {
    assert_eq!(u.len(), 4);
    ((u[3] as u32) << 0) | ((u[2] as u32) << 8) | ((u[1] as u32) << 16) | ((u[0] as u32) << 24)
}

pub fn as_u64_from8u8(u: &[u8]) -> u64 {
    assert_eq!(u.len(), 8);

    ((u[7] as u64) << 0)
        | ((u[6] as u64) << 8)
        | ((u[5] as u64) << 16)
        | ((u[4] as u64) << 24)
        | ((u[3] as u64) << 32)
        | ((u[2] as u64) << 40)
        | ((u[1] as u64) << 48)
        | ((u[0] as u64) << 56)
}

pub fn as_4u8_from_u32(data: u32) -> [u8; 4] {
    [
        (data >> 24) as u8,
        (data >> 16) as u8,
        (data >> 8) as u8,
        data as u8,
    ]
}
